const path = require('path');
const tsconfigPlugins = require('tsconfig-paths-webpack-plugin');
const currentDir = path.resolve(__dirname);

const workDir = path.resolve(currentDir);
console.log("当前工作路径:" + workDir);

module.exports = {
    // 监听
    watch: true,
    watchOptions: {
        poll: 1000, // 每秒询问多少次
        aggregateTimeout: 500,  //防抖 多少毫秒后再次触发
        ignored: /node_modules/ //忽略时时监听
    },
    entry: {
        client: path.resolve(workDir, './src/client/ClientStart.ts'),
        debugger: path.resolve(workDir, './src/client/debug_inject/DebugInject.ts'),
    },
    output: {
        filename: '[name].js',
        path: path.resolve(workDir, './bin/client/js'),
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/,
            },
            {
                test: /\.(md|txt|glsl|vs|fs)$/,
                use: "raw-loader",
                exclude: /node_modules/
            },
        ],
    },
    resolve: {
        extensions: ['.tsx', '.ts', '.js', 'glsl', 'md', 'txt'],
        plugins: [
            new tsconfigPlugins({
                configFile: path.join(workDir, './tsconfig.json'),
            })
        ],
    },
    devtool: 'source-map',
    mode: 'development',
};